#ifndef _BUOLA_GUI_WIDGETS_CLBLISTRENDERER_H_
#define _BUOLA_GUI_WIDGETS_CLBLISTRENDERER_H_

#include <buola/widgets/clbrenderer.h>

namespace buola { namespace gui {

class CLBListRenderer : public CLBRenderer
{
public:
    CLBListRenderer(CListBox*);
    virtual ~CLBListRenderer();
    
public:
////////////// Event handling //////////////
    virtual void OnSize(const CGeometryEvent &pE);
    virtual void OnExpose(const CExposeEvent &pE);

    virtual void OnBigChange();
    virtual void OnItemSelected(CListBox::SItem*);
    virtual void OnItemAdded(CListBox::SItem*);
    virtual void OnItemChanged(CListBox::SItem*);
    virtual void OnItemRemoved(CListBox::SItem*);
    virtual void OnXScrollChanged(int);
    
protected:
/////////////// protected functions //////////////
    //general functions
    void CalcAll();

    //item functions
    void InitItem(CListBox::SItem*);
    void DeinitItem(CListBox::SItem*);
    void PreshapeItem(CListBox::SItem*);    //calc min size
    void ShapeItem(CListBox::SItem*);       //calc size and shape
    void DrawItem(img::CGC*,CListBox::SItem*);
    void RedrawItem(CListBox::SItem*,bool);
    int HitTestItem(CListBox::SItem*,const CPoint_d&);
    int HitTestItem(CListBox::SItem*,const CRect_d&);

    //list functions
    void PreshapeAll();
    void ShapeAll();
    void PosAll(int=0);
    void DrawAll(img::CGC*);
    void DrawAll(img::CGC*,const CRect_d&);
    
    virtual CSize_d GetIconSize()       {   return mIconSize;   }
    virtual CSize_d GetMaxImageSize()   {   return mIconSize;   }

    virtual PEditBox Edit(CListBox::SItem*);
    virtual CPoint_d GetIconPos(CListBox::SItem*);
    virtual CRect_d GetItemRect(CListBox::SItem*);
    
    //params
    CSize_d mIconSize;
    double mTextEnd;
    double mTotalEnd;
    double mMinTextHeight;

    //preshaping
    double mMaxIconWidth;

    //positioning

    img::PFont mFont;

/////////////////// static data ////////////////////
};

/*namespace gui*/ } /*namespace buola*/ }

#endif
